class Solution:
    def removeDuplicates(self, nums) -> int:
        i = 1
        while i < len(nums) - 1:
            if nums[i-1] == nums[i+1]:
                nums.pop(i)
            else:
                i += 1
        return len(nums)


a = Solution()
print(a.removeDuplicates([1,1,1,2,2,3]))
print(a.removeDuplicates([0,0,1,1,1,1,2,3,3]))